//
//  SettingsTableViewCell.m
//  LiveEducation
//
//  Created by Liu,Qingcan on 2017/4/12.
//  Copyright © 2017年 Baidu. All rights reserved.
//

#import "SettingsTableViewCell.h"
@interface SettingsTableViewCell()

@property (nonatomic,strong)UIImageView *settingImageView;
@property (nonatomic,strong)UILabel *settingLabel;
@end

@implementation SettingsTableViewCell



- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

+(instancetype) initWithTableView:(UITableView *)tableView imageName:(NSString *) name title:(NSString *)title{
    static NSString *identifier = @"settingCell";
    SettingsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (!cell) {
        cell = [[SettingsTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
        cell.settingImageView.image = [UIImage imageNamed:name];
        cell.settingLabel.text = title;
    }
    return cell;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self settupViews];
    }
    return self;
}


- (void)settupViews{
    [self.contentView addSubview:self.settingLabel];
    [self.contentView addSubview:self.settingImageView];
}


- (UIImageView *)settingImageView{
    if (!_settingImageView) {
        _settingImageView = [[UIImageView alloc]initWithFrame:CGRectMake(25, self.bounds.size.height/2.f-15, 30, 30)];
        _settingImageView.contentMode = UIViewContentModeScaleToFill;
//        _settingImageView.
    }
    return _settingImageView;
}

- (UILabel *)settingLabel{
    if (!_settingLabel) {
        _settingLabel = [[UILabel alloc]initWithFrame:CGRectMake(75.f, self.bounds.size.height/2.f-17, 100.f, 34.f)];
        _settingLabel.textAlignment = NSTextAlignmentLeft;
        _settingLabel.textColor = [UIColor colorWithRed:70.f/255 green:49.f/255 blue:49.f/255 alpha:1];
        _settingLabel.font = [UIFont systemFontOfSize:15];
    }
    return _settingLabel;
}

@end
